技术文档|Apollo Release Build 简介
概览
Release Build实施原则
如何运行Apollo Release Build
如何使用Release Build输出运行Apollo
如何使用Install规则安装自定义模块
Install-Bazel 规则的参数
当前Release Build实现的局限性
在很长一段时间内,基于CyberRT的Apollo无法获得二进制分布。用户必须在Apollo Dev容器中自己构建整个项目,然后才能运行各种模块和工具。在某些情况下,这种无法部署的状况会产生麻烦。例如,使用SVL Simulator模拟器,所有Docker镜像、卷和Bazel缓存以及构建工件的总大小达到40+GB,这对于他们来说是相当不便的。
这种无法工作的根本原因是Bazel缺少与其他构建系统(例如,make install)中提供的类似的开箱即用的安装支持。
为了解决这个问题,我们借鉴了Drake项目的思路install,用Starlark语言实现了扩展,可以用来安装二进制文件、共享库、资源文件(配置、数据、启动文件、dags等)和文档。
ldd bazel-bin/modules/planning/libplanning_component.so
将显示以下输出:
linux-vdso.so.1 (0x00007ffc8a77c000)
libmodules_Splanning_Slibplanning_Ucomponent_Ulib.so => /apollo/bazel-bin/modules/planning/../../_solib_local/libmodules_Splanning_Slibplanning_Ucomponent_Ulib.so (0x00007fe8a7f9f000)
libmodules_Splanning_Slibnavi_Uplanning.so => /apollo/bazel-bin/modules/planning/../../_solib_local/libmodules_Splanning_Slibnavi_Uplanning.so (0x00007fe8a7d81000)
libmodules_Splanning_Slibon_Ulane_Uplanning.so => /apollo/bazel-bin/modules/planning/../../_solib_local/libmodules_Splanning_Slibon_Ulane_Uplanning.so (0x00007fe8a7b53000)
libmodules_Splanning_Slibplanning_Ubase.so => /apollo/bazel-bin/modules/planning/../../_solib_local/libmodules_Splanning_Slibplanning_Ubase.so (0x00007fe8a7945000)
libmodules_Splanning_Scommon_Ssmoothers_Slibsmoother.so => /apollo/bazel-bin/modules/planning/../../_solib_local/libmodules_Splanning_Scommon_Ssmoothers_Slibsmoother.so (0x00007fe8a7739000)
libmodules_Splanning_Splanner_Slibplanner_Udispatcher.so => /apollo/bazel-bin/modules/planning/../../_solib_local/libmodules_Splanning_Splanner_Slibplanner_Udispatcher.so (0x00007fe8a752e000)
...
要为Apollo生成二进制输出,只需运行:
./apollo.sh release -c
其中 -c 是用于预清洗的可选参数。输出位于Apollo Dev容器中的/apollo/output。
上述命令大致相当于以下命令:
bazel run --config=opt --config=gpu //:install \
-- --pre_clean /apollo/output
请键入./apollo.sh release-h以了解apollo.sh release的更多用法。
bash docker/scripts/runtime_start.sh
bash docker/scripts/runtime_start.sh -g cn
bash docker/scripts/runtime_into.sh
./scripts/bootstrap.sh
install(
name = "install",
deps = [
"//cyber:install",
# ...
"//modules/planning:install",
# ...
],
)
filegroup(
name = "planning_conf",
srcs = glob([
"conf/**",
]),
)
filegroup(
name = "runtime_data",
srcs = glob([
"dag/*.dag",
"launch/*.launch",
]) + [":planning_conf"],
)
install(
name = "install",
data = [
":runtime_data",
],
targets = [
":libplanning_component.so",
],
deps = [
"//cyber:install",
],
)
从tools/install/install.bzl:
install = rule(
attrs = {
"deps": attr.label_list(providers = [InstallInfo]),
"data": attr.label_list(allow_files = True),
"data_dest": attr.string(default = "@PACKAGE@"),
"data_strip_prefix": attr.string_list(),
"targets": attr.label_list(),
"library_dest": attr.string(default = "@PACKAGE@"),
"library_strip_prefix": attr.string_list(),
"mangled_library_dest": attr.string(default = "lib"),
"mangled_library_strip_prefix": attr.string_list(),
"runtime_dest": attr.string(default = "bin"),
"runtime_strip_prefix": attr.string_list(),
"rename": attr.string_dict(),
"install_script_template": attr.label(
allow_files = True,
executable = True,
cfg = "target",
default = Label("//tools/install:install.py.in"),
),
},
executable = True,
implementation = _install_impl,
)
Install规则的详细属性如下所示:
仅支持 C++,Python 安装尚未准备就绪。
仅支持 x86_64,ARM64 支持目前尚未准备就绪。
*《Apollo Release Build 简介》
https://github.com/ApolloAuto/apollo/blob/master/docs/technical_tutorial/intro_to_apollo_release_build.md